package com.yeyks.controller.hotel;

import com.yeyks.common.ajax.AjaxResponseBody;
import com.yeyks.common.base.Arguments;
import com.yeyks.common.base.PageResult;
import com.yeyks.common.param.hotel.RecommendHotelAddParam;
import com.yeyks.common.param.hotel.RecommendHotelListParam;
import com.yeyks.common.param.hotel.RecommendHotelUpdateParam;
import com.yeyks.hotel.dto.HotelRecommendDTO;
import com.yeyks.hotel.service.HotelRecommendService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * @author fuchangshuai
 * @since 2019-07-03
 */
@Api(tags = "推荐酒店模块")
@RestController
@RequestMapping(value = "/recommend/hotel")
public class HotelRecommendController {

    @Autowired
    private HotelRecommendService hotelRecommendService;

    @ApiOperation(value = "v4.0.0 --> 列表", response = HotelRecommendDTO.class)
    @PostMapping(value = "/list")
    public AjaxResponseBody<PageResult<HotelRecommendDTO>> list(@Validated RecommendHotelListParam param) {
        PageResult<HotelRecommendDTO> hotelRecommends = hotelRecommendService.myList(param);
        return AjaxResponseBody.success(hotelRecommends);
    }

    @ApiOperation(value = "v4.0.0 --> 新增酒店")
    @PostMapping(value = "/add")
    public AjaxResponseBody<Boolean> add(@Validated RecommendHotelAddParam param) {
        return AjaxResponseBody.success(hotelRecommendService.add(param));
    }

    @ApiOperation(value = "v4.0.0 --> 编辑酒店")
    @PostMapping(value = "/update")
    public AjaxResponseBody<Boolean> update(@Validated RecommendHotelUpdateParam param) {
        return AjaxResponseBody.success(hotelRecommendService.myUpdate(param));
    }

    @ApiOperation(value = "v4.0.0 --> 删除酒店")
    @PostMapping(value = "/del")
    public AjaxResponseBody<Boolean> del(Integer id) {
        Arguments.intIsNull(id, "推荐酒店id不能为空");
        return AjaxResponseBody.success(hotelRecommendService.removeById(id));
    }

}